﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QPEngine
{
    public static class CsExten
    { /// <summary>
      /// 移除 .xxx
      /// </summary>
      /// <returns></returns>
        public static string RemoveSuffix(this string args)
        {
            if (args.Contains("."))
            {
                string[] arry = args.Split('.');
                args = arry[0];
            }
            return args;
        }
        /// <summary>
        /// 将数组的元素依次向前移动一位,(第2个元素放到第一,第一放到最后去)
        /// </summary>
        public static string[] SortArray(this string[] args)
        {
            string item = string.Empty;
            item = args[0];
            for (int i = 0; i < args.Length - 1; i++)
            {
                args[i] = args[i + 1];
            }
            args[args.Length - 1] = item;
            return args;
        }

        /// <summary>
        /// 将指定的元素放到第一个位置
        /// </summary>
        public static string[] SortConst(this string[] args, int idex)
        {
            if (args.Length > idex) { return args; }
            string item = args[0];
            args[0] = args[idex];
            args[idex] = item;
            return args;
        }
        public static bool IsNullOrEmpty(this string args)
        {
            if (args == null) { return true; }
            if (args == string.Empty) { return true; }
            return false;
        }

    }
}
